<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>组件child状态</title>
    <script src="https://unpkg.com/vue/dist/vue.js"></script>
</head>

<body>
    <div id="app">
        <child ref="junior"></child>
        <p>真相：{{childStomach}}</p>
    </div>
    

    <script>
        Vue.component('child', {
            template: "<p>{{mouth}}</p>",
            data() {
                return {
                    mouth: "I didn't eat that cookie",
                    stomach: "Yummy that cookie was delicious."
                }
            }
        });

        new Vue({
            el: '#app',
            data: {
                childStomach: 'unknown'
            },
            mounted(){
                this.childStomach = this.$refs.junior.stomach;
            }
        })
    </script>
</body>

</html>